home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SS0288.ZIP / SS0288_6.TXT < prev   
Text File  |  1992-06-01  |  20KB  |  514 lines

  1. C4H OR C5H LINSYM--SYMBOL LINE NUMBERS RECORD
  2. =============================================
  3.  
  4. Description
  5. -----------
  6.  
  7. This record will be used to output line numbers for functions
  8. specified through COMDAT records. Each LINSYM record is associated
  9. with a preceding COMDAT record.
  10.  
  11. History
  12. -------
  13.  
  14. This record is a Microsoft extension for C 7.0.
  15.  
  16. Record Format
  17. -------------
  18.    1     2       1      1 or 2  2       2 or 4     1
  19.    C4    Record  Flags  Public  Line    Line       Checksum
  20.    or    Length         Name    Number  Number     
  21.    C5                   Index           Offset     
  22.                                 <---repeated--->   
  23.  
  24. Flags Field
  25. -----------
  26.           
  27. This field contains one defined bit:
  28.    
  29.   01H   Continuation bit. If clear, this COMDAT record establishes a
  30.         new instance of the COMDAT variable; otherwise, the data is a
  31.         continuation of the previous COMDAT of the symbol.
  32.    
  33. Public Name Index Field
  34. -----------------------
  35.  
  36. A regular logical name index, indicating the name of the base of the
  37. LINSYM record.
  38.  
  39. Line Number Field
  40. -----------------
  41.  
  42. An unsigned number in the range 0 to 65,535.
  43.  
  44. Line Number Offset Field
  45. ------------------------
  46.  
  47. The offset relative to the base specified by the symbol name base. The
  48. size of this field depends on the record type.
  49.   
  50.   NOTES
  51.   
  52.   Record type C5H is identical to C4H except that the Line Number
  53.   Offset field is 4 bytes instead of 2.
  54.   
  55.   This record is used to output line numbers for functions specified
  56.   through COMDAT records. Often, the residing segment as well as the
  57.   relative offsets of such functions is unknown at compile time, in
  58.   that the linker is the final arbiter of such information. For such
  59.   cases, the compiler will generate this record to specify the line
  60.   number/offset pairs relative to a symbolic name.
  61.   
  62.   This record will also be used to discard duplicate LINNUM
  63.   information. If the linker encounters two or more LINSYM records
  64.   with matching symbolic names (corresponding to multiple COMDAT
  65.   records with the same name), the linker will keep the one that
  66.   corresponds to the retained COMDAT.
  67.   
  68.   LINSYM records must follow the COMDATs to which they refer. A LINSYM
  69.   on a given symbol refers to the most recent COMDAT on the same
  70.   symbol.
  71.   
  72.   LINSYMs inherit the "localness" of their COMDATs.
  73.  
  74.  
  75. C6H ALIAS--ALIAS DEFINITION RECORD
  76. ==================================
  77.  
  78. Description
  79. -----------
  80.  
  81. This record has been introduced to support link-time aliasing, a
  82. method by which compilers or assemblers may direct the linker to
  83. substitute all references to one symbol for another.
  84.  
  85. History
  86. -------
  87.  
  88. The record is a Microsoft extension for FORTRAN version 5.1 (LINK
  89. version 5.13).
  90.  
  91. Record Format
  92. -------------
  93.  
  94.    1   2              <variable>   <variable>         1
  95.    C6  Record Length  Alias Name   Substitute Name    Checksum
  96.                       <-----------repeated--------->  
  97.    
  98.    Alias Name Field
  99.    ----------------
  100.    
  101.    A regular length-preceded name of the alias symbol.
  102.    
  103.    Substitute Name Field
  104.    ---------------------
  105.    
  106.    A regular length-preceded name of the substitute symbol.
  107.    
  108.   NOTES
  109.   
  110.   This record consists of two symbolic names: the alias symbol and the
  111.   substitute symbol. The alias symbol behaves very much like a PUBDEF
  112.   in that it must be unique. If a PUBDEF of an alias symbol is
  113.   encountered later, the PUBDEF overrides the alias. If another ALIAS
  114.   record with a different substitute symbol is encountered, a warning
  115.   is emitted by the linker, and the second substitute symbol is used.
  116.   
  117.   When attempting to satisfy an external reference, if an ALIAS record
  118.   whose alias symbol matches is found, the linker will halt the search
  119.   for alias symbol definitions and will attempt to satisfy the
  120.   reference with the substitute symbol.
  121.   
  122.   All ALIAS records must appear before the LINK Pass 2 record.
  123.  
  124.  
  125. C8H OR C9H NBKPAT--NAMED BACKPATCH RECORD
  126. =========================================
  127.  
  128. Description
  129. -----------
  130.  
  131. The Named Backpatch record is similar to a BAKPAT record, except that
  132. it refers to a COMDAT record, by logical name index, rather than an
  133. LIDATA or LEDATA record. NBKPAT records must immediately follow the
  134. COMDAT/FIXUPP block to which they refer.
  135.  
  136. History
  137. -------
  138.  
  139. This record is a Microsoft extension for C 7.0.
  140.  
  141. Record Format
  142. -------------
  143.    
  144.    1      2        1          1 or 2  2 or 4   2 or 4  1
  145.    C8     Record   Location   Public  Offset   Value   Checksum
  146.    or C9  Length   Type       Name
  147.                                       <---repeated---> 
  148.                                 
  149. Location Type Field
  150. -------------------
  151.           
  152. Type of location to be patched; the only valid values are:
  153.    
  154.    0    8-bit byte
  155.    1    16-bit word
  156.    2    32-bit double word, record type C9H only
  157.  
  158. Public Name Index Field
  159. -----------------------
  160.           
  161. Regular logical name index of the COMDAT record to be back patched.
  162.  
  163. Offset and Value Fields
  164. -----------------------
  165.    
  166. These fields are 32 bits for record type C8H, 16 bits for C9H.
  167.  
  168. The Offset field specifies the location to be patched, as an offset
  169. into the COMDAT.
  170.  
  171. The associated Value field is added to the location being patched
  172. (unsigned addition, ignoring overflow). The Value field is a fixed
  173. length (16 bits or 32 bits, depending on the record type) to make
  174. object module processing easier.
  175.  
  176.  
  177. CAH LLNAMES--LOCAL LOGICAL NAMES DEFINITION RECORD
  178. ==================================================
  179.  
  180. Description
  181. -----------
  182.  
  183. The LLNAMES record is a list of local names that can be referenced by
  184. subsequent SEGDEF and GRPDEF records in the object module.
  185.  
  186. The names are ordered by their occurrence, with the names in LNAMES
  187. records and referenced by index from subsequent records. More than one
  188. LNAMES and LLNAMES record may appear. The names themselves are used as
  189. segment, class, group, overlay, COMDAT, and selector names.
  190.  
  191. History
  192. -------
  193.  
  194. This record is a Microsoft extension for C 7.0.
  195.  
  196. Record Format
  197. -------------
  198.    
  199.    1         2         1         <--String Length--> 1
  200.    CA        Record    String    Name                Checksum
  201.              Length    Length    String              
  202.                        <----------repeated---------> 
  203.  
  204. Each name appears in <count, char> format, and a null name is valid.
  205. The character set is ASCII. Names can be up to 254 characters long.
  206.  
  207.   NOTE: Any LLNAMES records in an object module must appear before the
  208.   records that refer to them.
  209.   
  210.  
  211. APPENDIX 1: CODEVIEW EXTENSIONS
  212. ===============================
  213.  
  214. Calling the following information "CodeView's OMF" is a misnomer,
  215. since CodeView actually does very little to extend the OMF. Most
  216. CodeView information is stored within the confines of the existing
  217. OMF, except where noted below.
  218.  
  219. CodeView information is stored on a per-module basis in specially-
  220. named logical segments. These segments are defined in the usual way
  221. (SEGDEF records), but LINK handles them specially, and they do not end
  222. up as segments in the .EXE file. These segment names are reserved:
  223.  
  224.    Segment Name        Class Name          Combine Type
  225.    ------------        ----------          ------------
  226.  
  227.    $$TYPES             DEBTYP              Private
  228.    $$SYMBOLS           DEBSYM              Private
  229.  
  230. The segment $$IMPORT should also be considered a reserved name,
  231. although it is not used anymore. This segment was not part of any
  232. object files but was emitted by the linker to get the loader to
  233. automatically do fixups for CodeView information. The linker emitted a
  234. standard set of imports, not just ones referenced by the program being
  235. linked. Use of this segment may be revisited in the future.
  236.  
  237. CodeView-specific data is stored in LEDATA records for the $$TYPES and
  238. $$SYMBOLS segments, in various proprietary formats. The $$TYPES
  239. segment contains information on user-defined variable types; $$SYMBOLS
  240. contains information about nonpublic symbols: stack, local, procedure,
  241. block start, constant, and register symbols and code labels.
  242.  
  243. For instantiated functions in C 7.0, symbol information for CodeView
  244. will be output in COMDAT records that refer to segment $$SYMBOLS and
  245. have decorated names based on the function names. Type information
  246. will still go into the $$TYPES segment in LEDATA records.
  247.  
  248. All OMF records that specify a Type Index field, including EXTDEF,
  249. PUBDEF, and COMDEF records, use proprietary CodeView values. Since
  250. many types are common, Type Index values in the range 0 through 511
  251. (1FFH) are reserved for a set of predefined primitive types. Indexes
  252. in the range 512 through 32767 (200H-7FFFH) index into the set of type
  253. definitions in the module's $$TYPES segment, offset by 512. Thus 512
  254. is the first new type, 513 the second, and so on.
  255.  
  256.  
  257. APPENDIX 2: MICROSOFT MS-DOS LIBRARY FORMAT
  258. ===========================================
  259.  
  260. Libraries under MS-DOS are always multiples of 512-byte blocks.
  261.  
  262. The first record in the library is a header. This first record looks
  263. very much like any other Microsoft object module format record.
  264.  
  265.   Library Header Record (<n> bytes)
  266.   ---------------------------------
  267.                                                              
  268.    1     2                    4           2            1       <n - 10>
  269.    Type  Record Length        Dictionary  Dictionary   Flags   Padding
  270.                               Offest      Size
  271.    (F0H)  (Page Size Minus 3)             in Blocks            
  272.     
  273.    The first byte of the record identifies the record's type, and the
  274.    next two bytes specify the number of bytes remaining in the record.
  275.    Note that this word field is byte-swapped (that is, the low-order
  276.    byte precedes the high-order byte). The record type for this
  277.    library header is F0H (240 decimal).
  278.    
  279.    The Record Length field specifies the page size within the library.
  280.    Modules in a library always start at the beginning of a page. Page
  281.    size is determined by adding three to the value in the Record
  282.    Length field (thus the header record always occupies exactly one
  283.    page). Legal values for the page size are given by 2 to the <n>,
  284.    where <n> is greater than or equal to 4 and less than or equal to
  285.    15.
  286.    
  287.    The four bytes immediately following the Record Length field are a
  288.    byte-swapped long integer specifying the byte offset within the
  289.    library of the first byte of the first block of the dictionary.
  290.    
  291.    The next two bytes are a byte-swapped word field that specifies the
  292.    number of blocks in the dictionary. (The MS-DOS Library Manager
  293.    cannot create a library whose dictionary would require more than
  294.    251 512-byte pages.)
  295.    
  296.    The next byte contains flags describing the library. The current
  297.    flag definition is:
  298.    
  299.      0x01 = case sensitive (applies to both regular and extended
  300.      dictionaries)
  301.      
  302.    All other values are reserved for future use and should be 0.
  303.    
  304.    The remaining bytes in the library header record are not
  305.    significant. This record deviates from the typical Microsoft OMF
  306.    record in that the last byte is not used as a checksum on the rest
  307.    of the record.
  308.  
  309. Immediately following the header is the first object module in the
  310. library. It, in turn, is succeeded by all other object modules in the
  311. library. Each module is in Microsoft OMF (that is, it starts with a
  312. LHEADR record and ends with a MODEND record). Individual modules are
  313. aligned so as to begin at the beginning of a new page. If, as is
  314. commonly the case, a module does not occupy a number of bytes that is
  315. exactly a multiple of the page size, then its last block will be
  316. padded with as many null bytes as are required to fill it.
  317.  
  318. Following the last object module in the library is a record that
  319. serves as a marker between the object modules and the dictionary. It
  320. also resembles a Microsoft OMF record.
  321.  
  322.    Library End Record (marks end of objects and beginning of
  323.    dictionary)
  324.  
  325.    1           2                 <n>
  326.    Type (F1H)  Record Length     Padding
  327.    
  328.    The record's Type field contains F1H (241 decimal), and its Record
  329.    Length field is set so that the dictionary begins on a 512-byte
  330.    boundary. The record contains no further useful information; the
  331.    remaining bytes are insignificant. As with the library header, the
  332.    last byte is not a checksum.
  333.  
  334. Dictionary
  335. ----------
  336.    
  337. The remaining blocks in the library compose the dictionary. The number
  338. of blocks in the dictionary is given in the library header. Note that
  339. there should always be a prime number of blocks in the dictionary.
  340.  
  341. The dictionary is a hashed index to the library. Public symbols are
  342. essentially hashed twice, though in fact, both hash indexes are
  343. produced simultaneously. The first hash index, the block index, is
  344. used to determine a block within the dictionary in which to place the
  345. symbol. The second hash index, the bucket index, is used to choose a
  346. bucket within the block for the symbol. Blocks always have 37 buckets;
  347. they are the first 37 bytes of each block. If a bucket is full, it
  348. contains a nonzero value that points to the text of the symbol. To
  349. actually find the symbol, take the bucket value, multiply it by two,
  350. and use the resulting number as a byte offset from the beginning of
  351. the block.
  352.  
  353. Collisions (that is, two or more distinct symbols hashing to the same
  354. block and bucket in the dictionary) are resolved by a technique known
  355. as linear open addressing. At the same time the hash indexes are
  356. produced, two hash deltas are also produced. If a symbol collides with
  357. a symbol already installed in the dictionary, the librarian attempts
  358. to find an empty bucket for it by adding the bucket delta to the
  359. bucket index and using the result mod 37 as a new bucket index. If
  360. this new bucket index points to a bucket that is empty, the librarian
  361. will install the symbol in that bucket. If the bucket is not empty,
  362. the delta is applied repeatedly until an empty bucket is found or
  363. until it is determined that there are no empty buckets on the block.
  364. If the latter is the case, the block delta is added to the block
  365. index, and the result mod the number of blocks in the dictionary is
  366. used as a new block index. With the new block index and the original
  367. bucket index, the sequence is repeated until an empty bucket on some
  368. block is found.
  369.  
  370. The number of blocks and the number of buckets are prime so that no
  371. matter what values of hash indexes and deltas are produced for a
  372. symbol, in the worst case, all possible block-bucket combinations will
  373. be tried. Once a free block-bucket pair has been found for a symbol,
  374. the pair and information concerning its place of definition must be
  375. installed. Since a bucket is a single byte pointing into a 512-byte
  376. block, the bucket can give at best a word offset within that block.
  377. Thus, symbol entries within a dictionary must start on word
  378. boundaries. Since bytes 0 through 36 of each dictionary block make up
  379. the hash table, the first symbol entry will begin at byte 38
  380. (decimal).
  381.  
  382.    Dictionary Record (length is the dictionary size in 512-byte
  383.    blocks)
  384.  
  385.    37     1      <variable>  2                <conditional>
  386.    HTAB   FFLAG  Name        Block Number      Align Byte
  387.                  <-------------------repeated------------->
  388.    
  389.    Entries consist of the following: the first byte is the length of
  390.    the symbol to follow, the following bytes are the text of the
  391.    symbol, and the last two bytes are a byte-swapped word field that
  392.    specifies the page number (counting the library header as the 0th
  393.    page) at which the module defining the symbol begins.
  394.    
  395.    All entries may have at most one trailing null byte in order to
  396.    align the next entry on a word boundary.
  397.    
  398.    It is possible for a dictionary block to be full without all its
  399.    buckets being used. Such will be the case, for example, if symbol
  400.    names are longer on average than nine characters each. Therefore,
  401.    there must be some way to mark a block as full so that empty
  402.    buckets will be ignored.
  403.    
  404.    Byte 37 decimal (counting from 0) is reserved for this purpose. If
  405.    the block is not full, byte 37 will contain the word offset of the
  406.    beginning of free space in the block, but if the block is full,
  407.    byte 37 will contain the special value 255 decimal (FFH). Module
  408.    names are stored in the LHEADR record of each module.
  409.    
  410. Extended Dictionary
  411. -------------------
  412.  
  413. The extended dictionary is optional and indicates dependencies between
  414. modules in the library. Versions of LIB earlier than 3.09 do not
  415. create an extended dictionary. The extended dictionary is placed at
  416. the end of the library.
  417.  
  418. The dictionary is preceded by these values:
  419.  
  420.    BYTE =0xF2 Extended Dictionary header
  421.    WORD length of extended dictionary in bytes excluding first three
  422.         bytes
  423.  
  424. Start of extended dictionary:
  425.  
  426.    WORD number of modules in library = N
  427.  
  428. Module table, indexed by module number, with N + 1 fixed-length
  429. entries:
  430.  
  431.    WORD module page number
  432.    WORD offset from start of extended dictionary to list of required
  433.         modules
  434.  
  435. Last entry is null.
  436.  
  437. Dictionary Hashing Algorithm
  438. ----------------------------
  439.  
  440. The last part of each library file is a dictionary, which contains
  441. indexes to all symbols in the library. The dictionary is divided into
  442. 512-byte pages. Each page consists of a 37-byte bucket table and a 475-
  443. byte table of symbol entries.
  444.  
  445. To find the right spot in the dictionary for a given symbol, the
  446. hashing algorithm is used. The hashing algorithm analyzes the name of
  447. the symbol and produces two indexes: a page and a bucket index, which
  448. together point to a single entry in the dictionary. The only problem
  449. is that more than one symbol name can generate exactly the same
  450. address. Because of this, the name found in the dictionary entry must
  451. be compared with the symbol's name, and if they are not identical, a
  452. correction to the address must be made. To make this correction
  453. possible, the hashing algorithm, in addition to the base address
  454. (page, bucket), also produces the correction values (delta-page, delta-
  455. bucket), which are added to the base address if the symbol's name does
  456. not match the name in an entry. The number of pages in the dictionary
  457. must always be prime, so if the symbol is not found, the consecutive
  458. adding of deltas produces the starting address again.
  459.  
  460. Below is psueudocode illustrating the hashing algorithm used by the
  461. LIB (librarian) utility.
  462.  
  463.    extern char *symbol;   /* Symbol to find        */
  464.    extern int dictlength;  /* Dictionary length in pages  */
  465.    extern int buckets;   /* Number of buckets on one page */
  466.    
  467.    
  468.    
  469.    char *pb;  /* A pointer to the beginning of the symbol  */
  470.    char *pe;  /*   "      end     "      */
  471.    int slength;  /* Length of the symbol's name      */
  472.    
  473.    int page_index;   /*  Page index           */
  474.    int page_index_delta;/*  Page index delta        */
  475.    int page_offset;   /*  Page offset (bucket #)     */
  476.    int page_offset_delta;/* Page offset delta        */
  477.    
  478.    unsigned c;
  479.    
  480.    slength = strlen(symbol);
  481.    pb = symbol;
  482.    pe = symbol + slength;
  483.    page_index = 0;
  484.    page_index_delta = 0;
  485.    page_offset = 0;
  486.    page_offset_delta = 0;
  487.    
  488.    while( slength-)
  489.    {
  490.         c = *(pf++) | 32; /* Convert character to lowercase */
  491.         page_index = (page_index<<2) XOR c;    /* Hash */
  492.         page_offset_delta = (page_offset_delta>>2)XORc;
  493.         c = *(pe++) | 32;
  494.         page_offset = (page_offset>>2) XOR c;     /* Hash */
  495.         pageiindexdelta = (page_index_delta<<2) XOR c;
  496.    }
  497.    
  498.    /* Calculate page index */
  499.    page_index = page_index MODULO dictlength;
  500.    
  501.    
  502.    /* Calculate page index delta */
  503.    if((page_index_delta = page_index_delta MODULO dictlength) == 0)
  504.         page_index_delta = 1;
  505.    
  506.    
  507.    /* Calculate page offset */
  508.    page_offset = page_offset MODULO buckets;
  509.    
  510.    
  511.    /* Calculate page offset delta */
  512.    if( (page_offset_delta = page_offset_delta MODULO buckets) == 0)
  513.      page_offset_delta = 1;
  514.